#ifndef SSD1306_H
#define SSD1306_H

// Simple I2C test for ebay 128x64 oled.
// Use smaller faster AvrI2c class in place of Wire.
// Edit AVRI2C_FASTMODE in SSD1306Ascii.h to change the default I2C frequency.
//
#include "SSD1306Ascii.h"
#include "SSD1306AsciiAvrI2c.h"

// 0X3C+SA0 - 0x3C or 0x3D
#define I2C_ADDRESS 0x3C

// Define proper RST_PIN if required.
#define RST_PIN -1

SSD1306AsciiAvrI2c oled;
//------------------------------------------------------------------------------

void display_th_d() {
  oled.setCursor(30, 0);
  oled.set2X();
  if (distance_cm < 300) {
    oled.print(String(distance_cm, 0));
  } else {
    oled.print("   ");
  };
  oled.println("cm    ");
  //
  oled.print(" ");
  oled.print(t);  // text to display
  oled.print("C ");
  oled.print(h);  // text to display
  oled.print("%");
}


void setup_oled() {

#if RST_PIN >= 0
  oled.begin(&Adafruit128x64, I2C_ADDRESS, RST_PIN);
#else   // RST_PIN >= 0
  oled.begin(&Adafruit128x64, I2C_ADDRESS);
#endif  // RST_PIN >= 0
  // Call oled.setI2cClock(frequency) to change from the default frequency.

  oled.setFont(TimesNewRoman16_bold);
}

void loop_oled() {
  display_th_d();
}

#endif /* SSD1306_H */